﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Reflection;
using System.Threading;

using Azure.Logger;
using Azure.Configuration;
using Azure.Core;

namespace YourAzureTest
{
    class Program
    {
        static void Main(string[] args)
        {
            AzConfigManager.Init();
            AzCoreEngine.Instance.Init();
            AzCoreEngine.Instance.Start();
            AzCoreEngine.Instance.WaitForComplete();
            AzLogger.Info("正确");
            //AzXMLSerializer testee = new AzXMLSerializer("test.xml");

            //Thread t1 = new Thread(ThreadFun1);
            //Thread t2 = new Thread(ThreadFun2);
            //Thread t3 = new Thread(ThreadFun3);
            //t1.Start(testee);
            //t2.Start(testee);
            //t3.Start(testee);

            //Thread.Sleep(500);
            //testee.Dispose();

            //Console.ReadLine();
            //try
            //{
            //    XmlReaderSettings xsd = new XmlReaderSettings();
            //    xsd.ValidationType = ValidationType.Schema;
            //    xsd.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(XsdValidationEventHandler);
            //    xsd.Schemas.Add(null, XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("YourAzureTest.RobotConfig.xsd")));
            //    XmlReader reader = XmlReader.Create("azure.config", xsd);

            //    int i = 0;
            //    while (reader.Read())
            //    {
            //        i++;
            //    }
            //    Console.WriteLine(i);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.ToString());
            //}
        }

        //static void ThreadFun3(Object state)
        //{
        //    AzXMLSerializer testee = state as AzXMLSerializer;

        //    for (int i = 20000; i < 30000; i++)
        //    {
        //        AzNewDataBlock data = new AzNewDataBlock();
        //        AzNewDataBlock.AzDataCell cell = new AzNewDataBlock.AzDataCell();
        //        cell.ColumnName = "int";
        //        cell.CellValue = i;
        //        cell.ColumnType = typeof(Int32);
        //        data.DataSource = "test";
        //        data.DataCells.Add(cell.ColumnName, cell);

        //        testee.Serialize(data);
        //    }
        //}

        //static void ThreadFun2(Object state)
        //{
        //    AzXMLSerializer testee = state as AzXMLSerializer;

        //    for (int i = 10000; i < 20000; i++)
        //    {
        //        AzNewDataBlock data = new AzNewDataBlock();
        //        AzNewDataBlock.AzDataCell cell = new AzNewDataBlock.AzDataCell();
        //        cell.ColumnName = "int";
        //        cell.CellValue = i;
        //        cell.ColumnType = typeof(Int32);
        //        data.DataSource = "test";
        //        data.DataCells.Add(cell.ColumnName, cell);

        //        testee.Serialize(data);
        //    }
        //}

        //static void ThreadFun1(Object state)
        //{
        //    AzXMLSerializer testee = state as AzXMLSerializer;

        //    for (int i = 0; i < 10000; i++)
        //    {
        //        AzNewDataBlock data = new AzNewDataBlock();
        //        AzNewDataBlock.AzDataCell cell = new AzNewDataBlock.AzDataCell();
        //        cell.ColumnName = "int";
        //        cell.CellValue = i;
        //        cell.ColumnType = typeof(Int32);
        //        data.DataSource = "test";
        //        data.DataCells.Add(cell.ColumnName, cell);

        //        testee.Serialize(data);
        //    }
        //}

        static void ThreadFun(Object state)
        {
            Thread.Sleep(100);
            AzLogger.PerfStart("123");

            Thread.Sleep(5000);

            AzLogger.PerfEnd();
        }

        static void XsdValidationEventHandler(object sender, ValidationEventArgs e)
        {
            Console.WriteLine(e.ToString());
        }
    }
}
